From 9e861c1c9e552b4d98c8522a71cd034bdaf52060 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 8 Mar 2004 10:17:24 +0000 Subject: [PATCH] Make login work again; some var init fixes --- includes/SpecialRecentchanges.php | 2 +- includes/SpecialUserlogin.php | 63 +++++++++++++++++++------------ includes/User.php | 1 + 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index c356d1ed73..732115addf 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -127,7 +127,7 @@ function wfSpecialRecentchanges( $par ) if ( ! ( $hideminor && $obj->rc_minor ) ) { $rc = RecentChange::newFromRow( $obj ); - $s .= $sk->recentChangesLine( $rc, $obj->wl_user ); + $s .= $sk->recentChangesLine( $rc, !empty( $obj->wl_user ) ); --$limit; } } diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 5062ac5b1d..cecd6c5bb1 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -5,6 +5,7 @@ require_once('UserMailer.php'); function wfSpecialUserlogin() { global $wgCommandLineMode; + global $wgRequest; if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) { User::SetupSession(); } @@ -18,23 +19,26 @@ function wfSpecialUserlogin() # When switching accounts, it sucks to get automatically logged out global $wgLang; - if( $_REQUEST['returnto'] == $wgLang->specialPage( "Userlogout" ) ) $_REQUEST['returnto'] = ""; - - $wpCookieCheck = $_REQUEST[ "wpCookieCheck" ]; + if( $wgRequest->getVal( 'returnto' ) == $wgLang->specialPage( "Userlogout" ) ) { + $_REQUEST['returnto'] = ""; + } + + $wpCookieCheck = $wgRequest->getVal( "wpCookieCheck" ); if ( isset( $wpCookieCheck ) ) { onCookieRedirectCheck( $wpCookieCheck ); - } else if ( isset( $_REQUEST['wpCreateaccount'] ) ) { - addNewAccount(); - } else if ( isset( $_REQUEST['wpCreateaccountMail'] ) ) { - addNewAccountMailPassword(); - } else if ( isset( $_REQUEST['wpMailmypassword'] ) ) { - mailPassword(); - } else if ( "submit" == $_REQUEST['action'] || array_key_exists('wpLoginattempt', $_REQUEST) ) { - processLogin(); - } else { - mainLoginForm( "" ); + } else if( $wgRequest->wasPosted() ) { + if( $wgRequest->getCheck( 'wpCreateaccount' ) ) { + return addNewAccount(); + } else if ( $wgRequest->getCheck( 'wpCreateaccountMail' ) ) { + return addNewAccountMailPassword(); + } else if ( $wgRequest->getCheck( 'wpMailmypassword' ) ) { + return mailPassword(); + } else if ( "submit" == $wgRequest->getVal( 'action' ) || $wgRequest->getCheck( 'wpLoginattempt' ) ) { + return processLogin(); + } } + mainLoginForm( "" ); } @@ -98,6 +102,7 @@ function wfSpecialUserlogin() { global $wgUser, $wgOut; global $wgMaxNameChars; + global $wgRequest; if (!$wgUser->isAllowedToCreateAccount()) { userNotPrivilegedMessage(); @@ -131,7 +136,7 @@ function wfSpecialUserlogin() $u->addToDatabase(); $u->setPassword( $_REQUEST['wpPassword'] ); $u->setEmail( $_REQUEST['wpEmail'] ); - if ( 1 == $_REQUEST['wpRemember'] ) { $r = 1; } + if ( $wgRequest->getCheck( 'wpRemember' ) ) { $r = 1; } else { $r = 0; } $u->setOption( "rememberpassword", $r ); @@ -145,6 +150,7 @@ function wfSpecialUserlogin() { global $wgUser; global $wgDeferredUpdateList; + global $wgRequest; if ( "" == $_REQUEST['wpName'] ) { mainLoginForm( wfMsg( "noname" ) ); @@ -168,9 +174,9 @@ function wfSpecialUserlogin() # We've verified now, update the real record # - if ( 1 == $_REQUEST['wpRemember'] ) { + if ( $wgRequest->getCheck( 'wpRemember' ) ) { $r = 1; - $u->setCookiePassword( $_REQUEST['wpPassword'] ); + $u->setCookiePassword( $wgRequest->getText( 'wpPassword' ) ); } else { $r = 0; } @@ -273,7 +279,7 @@ function userNotPrivilegedMessage() /* private */ function mainLoginForm( $err ) { global $wgUser, $wgOut, $wgLang; - global $HTTP_COOKIE_VARS, $wgDBname; + global $wgRequest, $wgDBname; $le = wfMsg( "loginerror" ); $yn = wfMsg( "yourname" ); @@ -293,15 +299,15 @@ function userNotPrivilegedMessage() $endText = ""; } - $name = $_REQUEST['wpName']; + $name = $wgRequest->getText( 'wpName' ); if ( "" == $name ) { if ( 0 != $wgUser->getID() ) { $name = $wgUser->getName(); } else { - $name = $HTTP_COOKIE_VARS["{$wgDBname}UserName"]; + $name = $_COOKIE["{$wgDBname}UserName"]; } } - $pwd = $_REQUEST['wpPassword']; + $pwd = $wgRequest->getText( 'wpPassword' ); $wgOut->setPageTitle( wfMsg( "userlogin" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); @@ -319,18 +325,25 @@ color='red'>$err\n" ); } else { $checked = ""; } + $q = "action=submit"; - if ( "" != $_REQUEST['returnto'] ) { $q .= "&returnto=" . wfUrlencode($_REQUEST['returnto']); } + $returnto = $wgRequest->getVal( "returnto" ); + if ( !empty( $returnto ) ) { + $q .= "&returnto=" . wfUrlencode( $returnto ); + } + $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" ); $action = $titleObj->escapeLocalUrl( $q ); $encName = wfEscapeHTML( $name ); $encPassword = wfEscapeHTML( $pwd ); - $encRetype = wfEscapeHTML( $_REQUEST['wpRetype'] ); - $encEmail = wfEscapeHTML( $_REQUEST['wpEmail'] ); + $encRetype = wfEscapeHTML( $wgRequest->getText( 'wpRetype' ) ); + $encEmail = wfEscapeHTML( $wgRequest->getVal( 'wpEmail' ) ); if ($wgUser->getID() != 0) { $cambutton = ""; + } else { + $cambutton = ""; } $wgOut->addHTML( " @@ -355,8 +368,8 @@ color='red'>$err\n" ); "); if ($wgUser->isAllowedToCreateAccount()) { - $encRetype = htmlspecialchars( $_REQUEST['wpRetype'] ); - $encEmail = htmlspecialchars( $_REQUEST['wpCreateAccount'] ); + $encRetype = htmlspecialchars( $wgRequest->getText( 'wpRetype' ) ); + $encEmail = htmlspecialchars( $wgRequest->getText( 'wpEmail' ) ); $wgOut->addHTML("  $ypa: diff --git a/includes/User.php b/includes/User.php index 5e514802e5..f157b5cb95 100644 --- a/includes/User.php +++ b/includes/User.php @@ -504,6 +504,7 @@ class User { function logout() { + global $wgCookiePath, $wgCookieDomain, $wgDBname; $this->mId = 0; $_SESSION['wsUserID'] = 0; -- 2.20.1